#pragma once
#include "DXGIFactory.hpp"
#include "D3D12Fence.hpp"
#include "DXGIAdapter.hpp"
#include "D3D12CommandQueue.hpp"
namespace NAMESPACENAME
{
	namespace DirectX
	{
		class DXGIFactory;
		class D3D12Device final
		{
		protected:
			ID3D12Device9 * device;
			inline D3D12Device(ID3D12Device9* device) :
				device(device)
			{
			}
		public:
			static inline D3D12Device* Create(DXGIAdapter* adapter, D3D_FEATURE_LEVEL level)
			{
				if (ID3D12Device9* dev; SUCCEEDED(D3D12CreateDevice(adapter->adapter, level, IID_PPV_ARGS(&dev))))
					return new D3D12Device(dev);
				return nullptr;
			}
			inline D3D12Fence* CreateFence(UINT64 initialValue, D3D12_FENCE_FLAGS flags)const
			{
				if (ID3D12Fence1* fc; SUCCEEDED(device->CreateFence(initialValue, flags, IID_PPV_ARGS(&fc))))
					return new D3D12Fence(fc);
				return nullptr;
			}
			inline D3D12CommandQueue* CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC * pDesc)const
			{
				if (ID3D12CommandQueue* que; SUCCEEDED(device->CreateCommandQueue(pDesc, IID_PPV_ARGS(&que))))
					return new D3D12CommandQueue(que);
				return nullptr;
			}
			virtual ~D3D12Device();
		};
	}
}